import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class TaxPanel extends JPanel
{
	private final int WIDTH = 400;
	private final int HEIGHT = 100;
	
	private JLabel headingLabel;
	private JButton TenPercentButton, TwoHundredButton;
	private int returnValue; // 0 - no, 1 - yes

	public TaxPanel(String name)
	{
		setPreferredSize(new Dimension(WIDTH, HEIGHT));
		setBackground(new Color(200,222,186));
		returnValue = -1; // used to force user to choose yes or no
		
		headingLabel = new JLabel("Do you want pay 10% or $200?");
		
		add(headingLabel);
		
		TenPercentButton = new JButton("10%");
		TwoHundredButton = new JButton("$200");
		
		TenPercentButton.addActionListener(new ButtonListener());
		TwoHundredButton.addActionListener(new ButtonListener());
		add(TenPercentButton);
		add(TwoHundredButton);
	}
	
	private class ButtonListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
			Object source = event.getSource();
			if(source == TenPercentButton)
				returnValue = 10;
			else if(source == TwoHundredButton)
				returnValue = 200;
		}
	}
	
	
	public int getReturnValue()
	{
		return returnValue;
	}
	
	public void resetReturnValue()
	{
		returnValue = -1;
	}

}
